﻿@model IEnumerable<LabManagement.Data.Category>

@{
    ViewBag.Title = "Category";
    ViewBag.PageHeader = "Categories";
}
<div class="box">
    <div class="box-title">
        @Html.ActionLink("Add New", "AddNew", null, new { @Class="btn btn-primary pull-right"})
    </div>
    <div class="box-content nopadding">
        <table class="table table-hover table-nomargin table-bordered usertable">
            <thead>
                <tr class='thefilter'>
                    <th>
                        Name
                    </th>
                    <th>
                        Type
                    </th>
                    <th class="text-center">
                        Active
                    </th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @{var i=0; var delformId=string.Empty; }

                @foreach (var item in Model)
                {
                     i++;
                    delformId="del_"+i;
                    <tr>
                        <td class="col-md-5">
                            @Html.DisplayFor(modelItem => item.CategoryName)
                        </td>
                        <td class="col-md-3">
                            @Html.DisplayFor(modelItem => item.CategoryType)
                        </td>
                        <td class="col-md-1 text-center" >
                            @Html.DisplayFor(modelItem => item.Active)
                        </td>
                        <td class="col-md-2 text-center">
                            @*<a href="Categories/View/@item.CategoryId" class="btn" rel="tooltip" title="View">
                                <i class="fa fa-search"></i>
                            </a>*@
                            <a href="Categories/Edit/@item.CategoryId" class="btn" rel="tooltip" title="Edit">
                                <i class="fa fa-edit"></i>
                            </a>
                            <a href="#" data-id="@delformId" class="btn deleteaction" rel="tooltip" title="Delete">
                                <i class="fa fa-times"></i>
                            </a> 
                            @using (Html.BeginForm("delete", "Categories", new { id = @item.CategoryId }, FormMethod.Post, new { id = delformId }))
                            {
                                @Html.AntiForgeryToken()        
                            }
                            
                        </td>
                    </tr>
                }

            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4" class="text-right">
                            Pagination will come here
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
@section Scripts{
    <script type="text/javascript">
        $(".deleteaction").on("click", function () {
            if (confirm("Are you sure ? you wanted to delete this category")) {
                console.log("delCat_" + $(this).data("id"));
                $('#'+$(this).data("id")).submit();
            }
        });

    </script>    
 }

